﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.Framework.Core.MongoDB
{
    public static class MongoConfigure
    {
        /// <summary>
        /// 配置MongoDB
        /// </summary>
        /// <param name="services"></param>
        public static IServiceCollection ConfigureMongoDB(this IServiceCollection services, IConfiguration Configuration)
        {
            services.Configure<MongoConfig>(Configuration.GetSection("MongoDBSettings"));

            services.AddSingleton(typeof(IMongoBaseRepository<>), typeof(MongoBaseRepository<>));
            services.AddSingleton<MongoFactory>();

            return services;
        }
    }
}
